# coding=utf-8
from Page.base_page import BasePage
from Page.erp_default import ErpDefault
from Page.workflow_backend import WorkflowBackend

class Login(BasePage):
    # Login继承BasePage，并初始化Login的url给BasePage的base_url
    def __init__(self, url):
        super().__init__(base_url=url)

    # 进入登录页面
    def goto_main_page(self, user, password):
        self.input('name', 'user', user)
        self.input('name', 'pwd', password)
        self.click('name', 'submit')
        # 获取登录地址用于判断登录入口
        cur_url = self.driver.current_url
        # print(cur_url)
        if 'ProcessTodoList' in cur_url:
            return WorkflowBackend(self.driver)
        else:
            return ErpDefault(self.driver)
